#include "SnakerMap.h"
#include "SnakerPlayer.h"
#include "gtest/gtest.h"

using namespace std;

TEST(MapTest, OriginFit) {
    SnakerMap map;
    map.Init();
    EXPECT_TRUE(map.inChunk(0, 0, map.mapOrigin()));
    EXPECT_TRUE(map.inChunk(0, 0, map.FindChunk(0, 0)));
    
}

TEST(MapTest, ChunkCatcher) {
    SnakerMap map;
    map.Init();
    EXPECT_EQ(map.FindChunk(0, 0), map.GetChunk(0, 0));
}

TEST(MapTest, FruitMake) {
    SnakerMap map;
    map.Init();
    map.GenerateFruit(map.mapOrigin(), new SnakerFruit(vector<buff>{BUFF_SCORE_100, BUFF_LEN_1}, "P#2"));
    EXPECT_GE(map.ListFruit(map.mapOrigin()).size(), 0);
}

TEST(PlayerTest, LengthCheck) {
    SnakerMap map;
    map.Init();
    SnakerPlayer *player = new SnakerPlayer(map.mapOrigin(), &map);
    EXPECT_EQ(player->len, 3);
}

TEST(PlayerTest, BuffTest) {
    SnakerMap map;
    map.Init();
    SnakerPlayer *player = new SnakerPlayer(map.mapOrigin(), &map);
    SnakerCamera cam(4, 4);
    player->speed = 0;
    player->AddBuff(vector<buff>{BUFF_LEN_1, buff(0, 2)/* 持续两回合，每回合加100分 */});
    player->Update(0, &cam);
    EXPECT_EQ(player->len, 4);
    player->AddBuff(vector<buff>{BUFF_SCORE_100});
    player->Update(0, &cam);
    EXPECT_EQ(player->score, 300);
}